<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书管理系统</title>
	<script type="text/javascript" src="../../static/easyui/jquery.min.js" charset="utf-8"></script>
	<link id="easyuiTheme" rel="stylesheet" href="../../static/easyui/themes/ui-cupertino/easyui.css">
	<link rel="stylesheet" href="../../static/easyui/themes/icon.css">
	<link rel="stylesheet" href="../../static/font/css/font-awesome.min.css">
	<script type="text/javascript" src="../../static/easyui/jquery.easyui.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../static/easyui/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../static/js/easyui_datagrid_yzy.js" charset="utf-8"></script>
	<script type="text/javascript">
	$(function(){
			var h = document.documentElement.clientHeight || document.body.clientHeight;
			$('#t_table').datagrid({
				url:'pagelist',
				idField:'id',
				pagination:true,	//分页
				pageSize:5,
				pageList:[5,10,20],
				nowrap:false,
				height:h,
				fitColumns:true,	//宽度是否自适应
				striped:true,	//隔行变色 斑马色
				loadMsg:'数据正在疯狂的加载中...',//加载数据时显示的内容
				rownumbers:true,	//显示序号
				singleSelect:true,	//单选模式
				scrollbarSize:0,	//滚动条宽度
				columns:[ [
					{
						field:'id',
						title:'图片',
						width:8,
						align:"center",
						formatter:function(value,record,index){//鼠标悬停显示数据
							return '<img src="../book/download?id='+record.book.id+'" style="width: 110px;height:130px ;"/>';
						},
					},{
						field:'press',
						title:'书本信息',
						width:20,
						align:"center",
						formatter:function(value,record,index){//鼠标悬停显示数据
							return "书名："+record.book.name+"&emsp;ISBN："+record.book.isbn+"<br/>作者："+record.book.author+"&emsp;出版社："+record.book.press;
						},
					},{
						field:'startTime',
						title:'借书时间',
						width:10,
						align:"center",
					},{
						field:'number',
						title:'借书人信息',
						width:20,
						align:"center",
						formatter:function(value,record,index){//鼠标悬停显示数据
							return "姓名："+record.user.name+"&emsp;性别："+record.user.sex+"<br/>邮箱："+record.user.username+"&emsp;联系电话："+record.user.mynumber;
						},
						
					},{
						field:'loan',
						title:'操作',
						width:10,
						align:"center",
						formatter:function(value,record,index){//鼠标悬停显示数据
							var str = '<a  name="ok" onclick="oks('+record.id+')" class="easyui-linkbutton" ></a>';
							str+='<a name="no"onclick="no('+record.id+')" class="easyui-linkbutton" ></a>'
							return str;
						},
					}
				] ],
				onLoadSuccess:function(data){  
			        $("a[name='ok']").linkbutton({
			        	text:'同意',
			        	plain:true,
			        	iconCls:'icon-tag_blue'
			        }); 
			        $("a[name='no']").linkbutton({
			        	text:'拒绝',
			        	plain:true,
			        	iconCls:' icon-cross '
			        });
				},
		});
			
	});
	function oks(value){
		$.messager.confirm('请确定','是否同意？',function(r){
			if(r){//确定了
				$.post('ok',{id:value},function(result){
					//1.刷新数据表格
					$('#t_table').datagrid('reload');
					//2.清空idField
					$('#t_table').datagrid('unselectAll');
					//2.给提示信息
					$.messager.show({
						title:'提示',
						msg:'操作成功！已同意借书'
					});
				});
			}else{
				return ;
			}
		});
	};
	function no(value){
		$.messager.confirm('请确定','是否拒绝？',function(r){
			if(r){//确定了
				$.post('no',{id:value},function(result){
					//1.刷新数据表格
					$('#t_table').datagrid('reload');
					//2.清空idField
					$('#t_table').datagrid('unselectAll');
					//2.给提示信息
					$.messager.show({
						title:'提示',
						msg:'操作成功！已拒绝借书！'
					});
				});
			}else{
				return ;
			}
		});
	};
	</script>
</head>
<body>
	
			<table id="t_table"></table>
</body>
<script type="text/javascript">

</script>
</html>